package com.quxiu.system.mapper;

import java.util.List;
import com.quxiu.system.domain.BpmApprovalRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 审批记录Mapper接口
 *
 * @author quxiu
 * @date 2024-06-14
 */
@Mapper
public interface BpmApprovalRecordMapper {
    int insert(BpmApprovalRecord bpmApprovalRecord);
    int insertBatch(List<BpmApprovalRecord> bpmApprovalRecords);
    int deleteByProcInstId(@Param("procInstId") Long procInstId);

    List<BpmApprovalRecord> selectByProcInstId(@Param("procInstId") Long procInstId);
    List<BpmApprovalRecord> selectByNodeId(@Param("procInstId") Long procInstId, @Param("nodeId") Long nodeId);

    int updateStatus(@Param("recordId") Long recordId, @Param("handleStatus") String handleStatus);

    int updateHandleResult(BpmApprovalRecord result);

    BpmApprovalRecord selectByRecordId(@Param("recordId") Long recordId);

    /**
     * 删除未开始节点的审批记录
     * @param procInstId
     * @return
     */
    int deleteForUnStart(@Param("procInstId") Long procInstId);

    BpmApprovalRecord getStartNode(@Param("procInstId") Long procInstId, @Param("nodeId") Long nodeId);

    BpmApprovalRecord selectByParentId(@Param("procInstId") Long procInstId, @Param("nodeId") Long nodeId,
                                       @Param("parentId") Long parentId);

    void deleteByRecordId(@Param("recordId") Long recordId);

    /**
     * 获取当前节点未完成的审批记录数量
     * @param procInstId
     * @param nodeId
     * @return
     */
    int selectUnfinishedNumByNodeId(@Param("procInstId") Long procInstId, @Param("nodeId") Long nodeId);

    /**
     * 指定人的已审批记录数量
     * @param procInstId
     * @param handlerId
     * @return
     */
    int selectApprovedNum(@Param("procInstId") Long procInstId, @Param("handlerId") Long handlerId);

    void updateParentId(@Param("recordId") Long recordId, @Param("parentId") Long parentId);

    /**
     * 禁用自动审批
     * @param procInstId
     */
    void disableJoinAutoApprove(@Param("procInstId") Long procInstId);
}
